package com.example.fw;

import java.util.Collection;
import java.util.List;

import org.hibernate.Session;

public class HibernateHelper extends HelperBase {

		public HibernateHelper(ApplicationManager manager) {
		super(manager);
	}

	public String getLastGroupId() {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		return session.createQuery("select max(id) from GroupObject").uniqueResult().toString();
	}
	
	public Collection<GroupObject> getGroups() {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		return (List<GroupObject>) session.createQuery("from GroupObject").list();
	}
}
